package com.lagou.miaosha.rocketmq.mapper;

import com.lagou.miaosha.rocketmq.pojo.Order;
import com.lagou.miaosha.rocketmq.pojo.Stock;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Description TODO
 * @Classname OrderMapper
 * @Date 2021/7/21 20:21
 * @Author ch'ien
 */

@Mapper
public interface StockMapper {

    @Select("select * from `stock`")
    List<Stock> getList();

    @Select("select * from `stock` where goodsId = #{gid}")
    Stock getOneByGid(Integer gid);


    @Update("update stock set num = num + 1 where goodsId = #{id}")
    void incrementStock(Integer id);

    @Update("update stock set num = num - 1 where goodsId = #{id}")
    void decrementStock(Integer id);
}
